#include "chatuserwid.h"
#include "ui_chatuserwid.h"


ChatUserWid::ChatUserWid(QWidget *parent)
    : ListItemBase(parent)
    , ui(new Ui::ChatUserWid)
{
    ui->setupUi(this);
    SetItemType(ListItemBase::CHAT_USER_ITEM);
}

ChatUserWid::~ChatUserWid()
{
    delete ui;
}

void ChatUserWid::SetInfo(const QString& name, const QString& head, const QString& msg)
{
    _name = name;
    _head = head;
    _msg = msg;

    QPixmap pix(head);
    // 设置图片自动缩放
    ui->icon_id->setPixmap(pix.scaled(ui->icon_id->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
    ui->icon_id->setScaledContents(true);

    ui->user_name_label->setText(name);
    ui->user_chat_label->setText(msg);
}

